<!-- 进货记录页面 -->
<template>
  <div class="virtualWarehouse">
    <!-- 进货记录查询 -->
    <el-card class="searchCard" shadow="never" :body-style="{ padding: '20px' }">
      <div slot="header">
        <span>记录查询</span>
      </div>
      <el-form ref="searchForm" class="searchForm" :model="searchForm" label-width="100px" :inline="false" size="normal">
        <!-- 单据编号查询 -->
        <el-form-item label="单据编号:">
          <el-input v-model="searchForm.customerNum" style="width:200px" placeholder="请输入单据编号" size="small" clearable />
        </el-form-item>
        <!-- 供应方 -->
        <el-form-item label="供应方:">
          <el-input v-model="searchForm.connectPhone" style="width:200px" placeholder="请选择选择供应方" size="small" @focus="chooseSupplier" />
        </el-form-item>
        <!-- 开单时间选择 -->
        <el-form-item class="datePicker" label="开单时间:">
          <el-date-picker
            v-model="searchForm.value1"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            size="small"
          />
        </el-form-item>
        <!-- 商品名称 -->
        <el-form-item label="商品名称:">
          <el-input v-model="searchForm.conpanyName" style="width:200px" placeholder="请输入商品名称" size="small" clearable />
        </el-form-item>
        <!-- 进货状态 -->
        <el-form-item label="进货状态">
          <el-select v-model="searchForm.state" style="width:200px" size="small" placeholder="请选择">
            <el-option label="全部" value="0" />
            <el-option label="正常" value="1" />
            <el-option label="核销" value="2" />
          </el-select>
        </el-form-item>
        <!-- 查询和重置按钮 -->
        <el-form-item class="searchBtn">
          <el-button type="primary" size="small">查询</el-button>
          <el-button type="default" size="small">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <!-- 入库列表卡片 -->
    <el-card class="supplierList" shadow="never" :body-style="{ padding: '20px' }">
      <div slot="header">
        <span>入库表单</span>
        <!-- 新增入库按钮 -->
        <el-button type="primary" style="width:80px;margin-left:20px" size="small" @click="addreceipt">新增入库</el-button>
      </div>
      <template>
        <!-- 入库列表 -->
        <el-table
          :data="tableData"
          style="width: 100%"
          border
          :header-cell-style="{textAlign: 'center'}"
          :cell-style="{ textAlign: 'center' }"
        >
          <el-table-column
            prop="num"
            label="单据编号"
            width="200"
          />
          <el-table-column
            prop="customerNum"
            label="供应方联系人"
            width="200"
          />
          <el-table-column
            prop="attribute"
            label="商品名称"
          />
          <el-table-column
            prop="connectPhone"
            label="开单时间"
          />
          <el-table-column
            prop="companyName"
            label="应付金额"
          />
          <el-table-column
            prop="date"
            label="欠款"
          />
          <el-table-column
            prop="virtualWarehouse"
            label="状态"
          />
          <el-table-column
            label="操作"
            width="200"
          >
            <template slot-scope="scope">
              <el-button type="text" size="small" @click="checkPurchaseRecord">详情</el-button>
              <el-button type="text" size="small" @click="resetPassword(scope.row)">核销</el-button>
            </template>
          </el-table-column>
        </el-table>
        <!-- 选择供应商弹框 -->
        <el-dialog
          title="选择供应方"
          center
          :visible.sync="isChooseSupplier"
          width="80%"
        >

          <div class="supplierMessage">
            <!-- 搜索仓库部分 -->
            <el-card class="searchCard" shadow="never" :body-style="{ padding: '20px' }">
              <div slot="header">
                <span>搜索</span>
              </div>
              <el-form ref="searchForm" class="searchForm" :model="searchForm" label-width="100px" :inline="false" size="normal">
                <el-form-item label="搜索:">
                  <el-input v-model="searchForm.warehouseName" style="width:300px" placeholder="输入公司名称、联系人姓名、联系手机" size="small" clearable />
                </el-form-item>
                <el-form-item>
                  <el-button type="default" size="small">重置</el-button>
                  <el-button type="primary" size="small">查询</el-button>
                </el-form-item>
              </el-form>
            </el-card>
            <!-- 仓库列表卡片 -->
            <el-card class="supplierList" shadow="never" :body-style="{ padding: '20px' }">
              <div slot="header">
                <span>供应方列表</span>
                <el-button type="primary" style="margin-left:20px" size="small" @click="addWarehouse">新增供应方</el-button>
              </div>
              <template>
                <!-- 仓库列表 -->
                <el-table
                  :data="tableData"
                  style="width: 100%"
                  border
                  :header-cell-style="{textAlign: 'center'}"
                  :cell-style="{ textAlign: 'center' }"
                >
                  <el-table-column
                    prop="num"
                    label="序号"
                    width="200"
                  />
                  <el-table-column
                    prop="warehouseName"
                    label="公司名称"
                    width="200"
                  />
                  <el-table-column
                    prop="staff"
                    label="手机号"
                    width="200"
                  />
                  <el-table-column
                    prop="telephone"
                    label="联系人姓名"
                  />
                  <el-table-column
                    prop="contactPlace"
                    label="供应内容"
                  />
                  <el-table-column
                    label="操作"
                    width="400"
                  >
                    <template slot-scope="scope">
                      <el-button type="text" size="small" @click="editWarehouse(scope.row)">查看</el-button>
                      <el-button type="text" size="small" @click="deleteWarehouse">选中</el-button>
                    </template>
                  </el-table-column>
                </el-table>
                <!-- 新增供应方弹框 -->
                <el-dialog
                  title="新增供应方"
                  :visible.sync="addSupplier"
                  width="40%"
                  style="margin-top:120px;"
                  class="dialog"
                >
                  <div class="addWarehouse">
                    <!-- 添加虚拟仓弹框 -->
                    <el-form ref="addForm" class="addForm" :model="addForm" label-width="100px" :inline="false" size="normal">
                      <el-form-item label="供应方类型:">
                        <el-input v-model="addForm.warehouseName" style="width:400px" placeholder="供应方类型" size="small" clearable />
                      </el-form-item>
                      <el-form-item label="联系人姓名:">
                        <el-input v-model="addForm.staff" style="width:400px" placeholder="联系人姓名" size="small" clearable />
                      </el-form-item>
                      <el-form-item label="联系人手机号:">
                        <el-input v-model="addForm.telephone" style="width:400px" placeholder="联系人手机号" size="small" clearable />
                      </el-form-item>
                      <el-form-item label="公司名称:">
                        <el-input v-model="addForm.contactPlace" style="width:400px" placeholder="公司名称" size="small" clearable />
                      </el-form-item>
                      <el-form-item label="供应内容:">
                        <el-input v-model="addForm.remarks" style="width:400px" placeholder="50字以内" type="textarea" maxlength="50" size="small" show-word-limit :rows="2" />
                      </el-form-item>
                      <el-form-item label="备注:">
                        <el-input v-model="addForm.remarks" style="width:400px" placeholder="30字以内" type="textarea" maxlength="30" size="small" show-word-limit :rows="2" />
                      </el-form-item>
                      <el-form-item>
                        <el-button type="primary" style="width:100px;height:40px" size="small">提交</el-button>
                        <el-button type="default" style="width:100px;height:40px" size="small">取消</el-button>
                      </el-form-item>
                    </el-form>
                  </div>
                </el-dialog>
                <!-- 编辑虚拟仓弹框 -->
                <el-dialog
                  title="仓库信息"
                  :visible.sync="showEditWarehouse"
                  width="40%"
                  style="margin-top:120px;"
                  class="dialog"
                >
                  <div class="addWarehouse">
                    <!-- 编辑虚拟仓弹框表单 -->
                    <el-form ref="editWarehouseForm" class="addForm" :model="editWarehouseForm" label-width="100px" :inline="false" size="normal">
                      <el-form-item label="仓库名称:">
                        <el-input v-model="editWarehouseForm.warehouseName" style="width:400px" placeholder="仓库名称" size="small" clearable />
                      </el-form-item>
                      <el-form-item label="负责人:">
                        <el-input v-model="editWarehouseForm.staff" style="width:400px" placeholder="负责人" size="small" clearable />
                      </el-form-item>
                      <el-form-item label="联系电话:">
                        <el-input v-model="editWarehouseForm.telephone" style="width:400px" placeholder="联系电话" size="small" clearable />
                      </el-form-item>
                      <el-form-item label="联系地址:">
                        <el-input v-model="editWarehouseForm.contactPlace" style="width:400px" placeholder="联系地址" size="small" clearable />
                      </el-form-item>
                      <el-form-item label="备注:">
                        <el-input v-model="editWarehouseForm.remarks" style="width:400px" placeholder="30字以内" type="textarea" maxlength="30" size="small" show-word-limit :rows="2" />
                      </el-form-item>
                      <el-form-item>
                        <el-button type="primary" style="width:100px;height:40px" size="small">提交</el-button>
                        <el-button type="default" style="width:100px;height:40px" size="small">取消</el-button>
                      </el-form-item>
                    </el-form>
                  </div>
                </el-dialog>
                <div class="block">
                  <!-- 消息表格分页器 -->
                  <el-pagination
                    :current-page="currentPage4"
                    :page-sizes="[100, 200, 300, 400]"
                    :page-size="100"
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="400"
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                  />
                </div>
              </template>
            </el-card>
          </div>
        </el-dialog>

        <!-- 详情弹框 -->
        <el-dialog
          title="进货单详情"
          center
          :visible.sync="purchaseOrderDetails"
          width="60%"
        >
          <div class="purchaseInfo">
            <div>单据编号:</div>
            <div>开单时间:</div>
            <div>供应方:</div>
            <div>仓库:</div>
            <div>录单员:</div>
          </div>
          <el-table
            :data="tableData"
            style="width: 100%;margin-top:10px"
            border
            :header-cell-style="{textAlign: 'center'}"
            :cell-style="{ textAlign: 'center' }"
          >
            <el-table-column
              prop="num"
              label="序号"
              width="200"
            />
            <el-table-column
              prop="warehouseName"
              label="商品"
              width="200"
            />
            <el-table-column
              prop="staff"
              label="进货单价"
              width="200"
            />
            <el-table-column
              prop="telephone"
              label="进货数量"
            />
            <el-table-column
              prop="contactPlace"
              label="小计"
            />
            <el-table-column
              prop="contactPlace"
              label="批次"
            />
          </el-table>

          <!-- 合计以及小计价格 -->
          <div style="display:flex; justify-content: space-around;margin-top:10px">
            <div>合计： <span style="color:red">1500</span><span>元</span></div>
            <div>优惠后应付：<span style="color:red">1200</span><span>元</span></div>
          </div>
          <!-- 实付、欠款以及备注 -->
          <div style="display:flex; justify-content: space-between;flex-wrap:wrap;width:200px;margin-top:50px">
            <div>实付：<span style="color:red">1000</span><span>元</span></div>
            <div>欠款：<span style="color:red">200</span><span>元</span></div>
            <div style="margin-top:10px">备注：<span>123</span> </div>
          </div>
        </el-dialog>

        <!-- 重置密码弹框 -->
        <el-dialog title="重置密码" :visible.sync="dialogFormVisible">
          <el-form :model="resetPasswordForm">
            <el-form-item label="登录账号" size="normal">
              {{ costomerMessage.connectPhone }}
            </el-form-item>
            <el-form-item label="设置密码:" size="normal">
              <el-input v-model="costomerMessage.setPassword" placeholder="" size="normal" clearable />
            </el-form-item>
            <el-form-item label="确认密码:">
              <el-input v-model="costomerMessage.checkPassword" placeholder="" size="normal" clearable />
            </el-form-item>
          </el-form>
          <div slot="footer" class="dialog-footer">
            <el-button @click="dialogFormVisible = false">取 消</el-button>
            <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
          </div>
        </el-dialog>
        <div class="block">
          <!-- 消息表格分页器 -->
          <el-pagination
            :current-page="currentPage4"
            :page-sizes="[100, 200, 300, 400]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="400"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </template>

    </el-card>
  </div>
</template>

<script>
export default {
// import引入的组件需要注入到对象中才能使用，
  components: {},
  data() {
    // 这里存放数据
    return {
      purchaseOrderDetails: false, // 进货单详情
      addSupplier: false, // 新增供应方弹框
      editWarehouseForm: { // 编辑虚拟框信息

      },
      showEditWarehouse: false, // 编辑虚拟仓弹框
      addForm: { // 添加仓库数据
        warehouseName: '',
        staff: '',
        telephone: '',
        contactPlace: '',
        remarks: ''
      },
      isChooseSupplier: false, // 选择供应方弹框
      dialogFormVisible: false, // 重置密码表单现实隐藏
      resetPasswordForm: {
        setPassword: '', // 设置密码
        checkPassword: ''// 确认密码
      }, // 重置密码
      costomerMessage: {}, // 客户信息
      dialogVisible: false, // 控制查看表单显示
      searchForm: {
        state: '0', // 虚拟仓状态选择
        value1: [], // 查询日期
        companyName: '', // 供应商名字
        type: '4', // 客户类型
        attribute: '3', // 客户属性
        connectName: '', // 联系人姓名
        connectPhone: '', // 联系电话
        customerNum: ''// 客户编号
      },
      tableData: [{
        num: '01',
        customerNum: 'KH2110080001',
        customerType: '销售渠道',
        attribute: '企业',
        connectName: '张三',
        companyName: '微红健康',
        connectPhone: '17311111111',
        date: '2022-01-01',
        virtualWarehouse: '启用'
      }, {
        num: '02',
        customerNum: 'KH2110080001',
        customerType: '销售渠道',
        attribute: '企业',
        connectName: '张三',
        companyName: '微红健康',
        connectPhone: '17311111111',
        date: '2022-01-01',
        virtualWarehouse: '启用'

      }, {
        num: '03',
        customerNum: 'KH2110080001',
        customerType: '销售渠道',
        attribute: '企业',
        connectName: '张三',
        companyName: '微红健康',
        connectPhone: '17311111111',
        date: '2022-01-01',
        virtualWarehouse: '启用'
      }],
      currentPage4: 2 // 当前页数
    }
  },
  // 监听属性 类似于data概念
  computed: {},
  // 监控data中的数据变化
  watch: {},
  // 生命周期 - 创建完成（可以访问当前this实例）
  created() {

  },
  // 生命周期 - 挂载完成（可以访问DOM元素）
  mounted() {

  },
  beforeCreate() {}, // 生命周期 - 创建之前
  beforeMount() {}, // 生命周期 - 挂载之前
  beforeUpdate() {}, // 生命周期 - 更新之前
  updated() {}, // 生命周期 - 更新之后
  beforeDestroy() {}, // 生命周期 - 销毁之前
  destroyed() {}, // 生命周期 - 销毁完成
  activated() {},
  // 方法集合
  methods: {
    chooseSupplier() { // 点击打开选择供应方弹框
      this.isChooseSupplier = true
    },
    deleteWarehouse() {
      console.log('删除仓库')
    },
    editWarehouse(el) { // 编辑虚拟框信息
      this.showEditWarehouse = true
      this.editWarehouseForm = el
      console.log(this.editWarehouseForm)
    },
    addWarehouse() { // 跳转到添加供应方页面
      this.dialogVisible = true
    },
    resetPassword(el) { // 点击列表重置按钮
      // console.log('列表重置按钮')
      this.dialogFormVisible = true
      this.costomerMessage = el
    },
    editSupplier() {
      this.$router.push({ // 跳转到编辑供应商页面
        name: 'EditCustomer'
      })
    },
    checkPurchaseRecord(el) { // 查看进货单详情
      this.purchaseOrderDetails = true
    },
    addreceipt() { // 跳转到新增入库虚拟仓页面
      this.$router.push({
        name: 'AddReceipt'
      })
    },
    handleSizeChange(val) { // 分页器事件每页条数
      console.log(`每页 ${val} 条`)
    },
    handleCurrentChange(val) { // 分页器事件当前页
      console.log(`当前页: ${val}`)
    }
  } // 如果页面有keep-alive缓存功能，这个函数会触发
}
</script>
<style scoped lang="scss">
.virtualWarehouse{//虚拟仓样式
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #f0f2f5;
    .searchCard{//搜索卡片样式
      margin: 30px;
      .searchForm{//搜索表单样式
         display: flex;
        flex-wrap: wrap;
      }
    }
    .supplierList{//供应商列表
      margin: 30px;
    }
    .block{//分页器样式
      margin-top: 20px;
        padding: 20px;
        display: flex;
        justify-content: center;
      }
    .purchaseInfo{
      display: flex;
      justify-content: space-around;
    }
      .customerMessage{//客户信息样式
          padding: 0px 10px;
        div{
          margin-bottom: 20px;
        }
    }

}
</style>
